package com.wx.mythread.threadmethod;


/**
 * join的原理，代替写法
 */
public class StudyPrinciple {


    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                    System.out.println("Thread1 finished");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        thread.start();
        System.out.println("开始等待子线程运行完毕");
        // thread1.join();
        synchronized (thread){
            thread.wait();
        }
        System.out.println("所有子线程运行完毕");
    }
}
